
<template>
  <div class="home">
    <button @click="chagenName">修改name</button>
    <h2>store name:{{ $store.state.name }}</h2>
    <button @click="incrementLevel">递增levle</button>
    <button @click="changeInfo">修改信息</button>
    <h2>store level:{{ $store.state.level }}</h2>
    

  </div>
</template>
<script>
import { mapGetters } from 'vuex';
import {CHANGE_INFO} from "@/store/mutation_type"
export default {
  computed:{

  },
  methods:{
    chagenName(){
      // this.$store.state.name = "123321"
      this.$store.commit("changeName","inzv520")
    },
    incrementLevel(){
      
      this.$store.commit("incrementLevel")

    },
    changeInfo(){
      this.$store.commit(CHANGE_INFO,{
        name:"inzvdjsakl",
        level:200
      })
    }
  }
}
</script>

<script setup>
import {computed,toRefs} from 'vue'
 import { mapGetters, useStore } from 'vuex';
 const store = useStore()

// 3.针对某一个getters属性使用computed
const message = computed(()=>store.getters.message)
</script>
